#include <jni.h>
#include <stdio.h>

JNIEXPORT jint JNICALL Java_com_yaendrel_nativity_MainActivity_nativeMethod(JNIEnv *env, jobject obj) {
	//return fib(32);
	return 1;
}

int fib(int n) {
	if (n < 2) return n;
	else return fib (n - 1) + fib(n - 2);
}


JNIEXPORT jint JNICALL Java_com_yaendrel_nativity_MainActivity_nativeMemory(JNIEnv *env, jobject obj) {
	char A[1000][1000];
	int i, j;
	for (i = 0; i < 1000; i++) {
		for (j = 0; j < 1000; j++) {
			A[i][j] = 'a';
		}
	}
	return A[999][999];
	//return 1;
}

JNIEXPORT jint JNICALL Java_com_yaendrel_nativity_MainActivity_nativeProcInt(JNIEnv *env, jobject obj, jint k) {
	int i = 0, j = 0;
	while (i < 2000000+k) {
		j = i+(i-k);
		i = j-(i+k);
		i++;
	}
	return i+k;
}

JNIEXPORT jint JNICALL Java_com_yaendrel_nativity_MainActivity_nativeProcFloat(JNIEnv *env, jobject obj, jint k) {
	float i = 0.0, j = 0.0;
	while (i < 2000000+k) {
		j = i*(i+k);
		j = j/(i+k);
		i++;
	}
	return i+k;
}

JNIEXPORT jint JNICALL Java_com_yaendrel_nativity_MainActivity_nativeDisk(JNIEnv *env, jobject obj) {
	FILE* teste = fopen("/sdcard/teste.native.txt", "w+");
	if (teste != NULL) {
		int i;
		for (i = 0; i < 5120; i++) fputc('n', teste);
	}
	fclose(teste);
	return 0;
}

